﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.IO;
using System.Text;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.MODE;
namespace EnvironmentManagerSystem.EvaluationUnitManager
{
    public partial class ReadOnly : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                InitUI();
            }
        }

        private void InitUI()
        {
            if (Session["evaluationunitID"].ToString() != null)
            {
                EvaluationUnitData model = EvaluationUnit.GetModel(Convert.ToInt32(Session["evaluationunitID"].ToString()));
                this.txtUnitName.Text = model.UnitName;
                this.txtAddress.Text = model.Address;
                this.txtCertificateNo.Text = model.CertificateNo;
                this.txtPhone.Text = model.Phone;
                this.txtZipCode.Text = model.ZipCode;
                this.txtEvaluationScope.Text = model.EvaluationScope;
                this.txtLoginName.Text = model.LoginName;
                this.txtPwd.Text = model.PassWord;
                Image1.ImageUrl = model.QualificationFileURL;
                Image2.ImageUrl = model.AllSignedURL;
                BindGv();
            }
        }

        private void BindGv()
        {
            if (Session["userid"].ToString() != null)
            {
                gvLeader.DataSource = ProjectLeader.GetList(Convert.ToInt32(Session["evaluationunitID"].ToString()));
                gvLeader.DataBind();
            }
        }

        protected void gvLeader_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int ID = Convert.ToInt32(gvLeader.DataKeys[e.NewEditIndex].Value);
            Response.Redirect("ProjectLeaderEdit.aspx?ID=" + ID);
        }

        protected void gvLeader_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int ID = Convert.ToInt32(gvLeader.DataKeys[e.RowIndex].Value);
            bool result = ProjectLeader.Delete(ID);
        }

        protected void btnSave0_Click(object sender, EventArgs e)
        {
            gvLeader.DataSource = ProjectLeader.GetLists(Session["evaluationunitID"].ToString());
            gvLeader.DataBind();
        }
    }
}
